package com.bjtech.web.action.management;

import com.bjtech.dao.BaseCommunityInfoDao;
import com.bjtech.domain.BaseCommunityInfo;
import com.bjtech.domain.query.BaseCommunityInfoQuerySpec;
import com.bjtech.web.action.LyheatBaseAction;

public class BaseCommunityInfoAction extends LyheatBaseAction {

	private static final long serialVersionUID = 1L;
	private BaseCommunityInfoDao baseCommunityInfoDao;
	private BaseCommunityInfoQuerySpec selectBean;
	
	public void prepare() throws Exception {

	}
	
	public BaseCommunityInfoAction() throws Exception{
		model = new BaseCommunityInfo();
		selectBean = new BaseCommunityInfoQuerySpec();
	}
	
	public void setBaseCommunityInfoDao(BaseCommunityInfoDao baseCommunityInfoDao) {
		this.baseCommunityInfoDao = baseCommunityInfoDao;
	}

	public String execute(){
		return this.list();
	}
	
	public String list(){
		selectBean.queryParamString();
		list = this.baseCommunityInfoDao.selectEntityPaginatedList(new BaseCommunityInfo(),selectBean);
		return "list";
	}
	
	public String add(){
		return "edit";
	}
	
	public String save(){
		BaseCommunityInfo entity = (BaseCommunityInfo)model;
		if(entity.getId()==null){
			baseCommunityInfoDao.insertEntity(entity);
		}else{
			baseCommunityInfoDao.updateEntity(entity);
		}
		return "success";
	}
	
	public String edit(){
		model = this.baseCommunityInfoDao.selectEntity(new BaseCommunityInfo(),id);
		return "edit";
	}

	public String view(){
		model = this.baseCommunityInfoDao.selectEntity(new BaseCommunityInfo(),id);
		return "view";
	}
	
	public String delete(){
		model = this.baseCommunityInfoDao.deleteEntity(new BaseCommunityInfo(),id);
		return "success";
	}
	
	public BaseCommunityInfoQuerySpec getSelectBean() {
		return selectBean;
	}

	public void setSelectBean(BaseCommunityInfoQuerySpec selectBean) {
		this.selectBean = selectBean;
	}
}
